package com.moli.iov.down.command.design.strategy.commandreqdto.impl;

import com.moli.iov.down.enums.command.CommandEnum;
import com.moli.iov.down.enums.command.TerminalSettingEnum;
import com.moli.iov.down.model.dto.remoting.CommandDto;
import com.moli.iov.down.model.dto.remoting.CommandReqDto;
import com.moli.iov.down.model.dto.remoting.extend.CommandExtendDto;
import com.moli.iov.down.command.design.strategy.commandreqdto.CommandReqDtoStrategy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * <p>
 *  端口
 * </p>
 *
 * @author: zql
 * @Date: 2018/12/28 11:59
 */
public class ChangePortStrategy implements CommandReqDtoStrategy {

    @Override
    public CommandDto make(CommandReqDto commandReqDto) {
        CommandDto commandDto = new CommandDto();
        commandDto.setVin(commandReqDto.getVin());
        commandDto.setIsRetry(commandReqDto.getIsRetry());

        commandDto.setCommand(CommandEnum.TERMINAL_PARAMETER_SETTING.getFlag());

        List<String> parameterIds = Arrays.asList(TerminalSettingEnum.PORT.getFlag());
        commandDto.setParameterIds(parameterIds);


        List<CommandExtendDto> commandExtendDtos = new ArrayList<>();
        CommandExtendDto commandExtendDtoPort = new CommandExtendDto();
        commandExtendDtoPort.setParameterId(TerminalSettingEnum.PORT.getFlag());
        commandExtendDtoPort.setParameterContent(String.valueOf(commandReqDto.getPort()));
        commandExtendDtos.add(commandExtendDtoPort);

        commandDto.setCommandExtendDtos(commandExtendDtos);

        return commandDto;
    }
}
